import request from '@/config/axios'

export interface ChannelVO {
  id: number
  channelName: string
  channelCode: string
  accessNotifyUrl: string
  accessTokenExpire: number
  appId: string
  appKey: string
  appSecret: string
  remark: string
  icon: string
}


export interface ChannelListVO {
  id: number
  channelName: string
  icon: string
}

// 查询广告平台分页
export const getChannelPage = async (params) => {
  return await request.get({ url: `/operate/channel/page`, params })
}

// 查询广告平台详情
export const getChannel = async (id: number) => {
  return await request.get({ url: `/operate/channel/get?id=` + id })
}

// 新增广告平台
export const createChannel = async (data: ChannelVO) => {
  return await request.post({ url: `/operate/channel/create`, data })
}

// 修改广告平台
export const updateChannel = async (data: ChannelVO) => {
  return await request.put({ url: `/operate/channel/update`, data })
}

// 删除广告平台
export const deleteChannel = async (id: number) => {
  return await request.delete({ url: `/operate/channel/delete?id=` + id })
}

// 导出广告平台 Excel
export const getChannelList = async () => {
  return await request.get({ url: `/operate/channel/list` })
}

/**
 * 获取授权URL；
 * 
 * @param channelId 
 * @returns 
 */
export const getChannelAuthUrl = async (channelId: number) => {
  return await request.get({ url: `/operate/channel/get-channel-auth-url?channelId=` + channelId })
}